import {defineStore} from  'pinia'  
import {
    getUserInfo,
} from '@/api'
const useUserStore = defineStore('user', {
    state: () => ({
        userMessage: {},//用户信息





    }),
    actions: {
        //获取用户信息
        async getUserInfo() {
            const res = await getUserInfo()
            this.userMessage = res.data
        },
        //判断用户是否已经登录
        isLogin() {
            // return !!this.userMessage
            return Object.keys(this.userMessage).length > 0;
        },
        //退出登录
        logout() {
            this.userMessage = {}
        }
    }





})
export default useUserStore;